home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Graphics & Imaging / Printer Drivers / Print Queue ƒ 1.1 / PrintQueue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-25  |  4.8 KB  |  180 lines  |  [TEXT/KAHL]

  1. /*
  2.         © Copyright 1989 Apple Computer, Inc.
  3.         
  4.         By Ricardo Batista
  5.         
  6.         
  7.         This file contains a code resource which is used within 4-Dimension
  8.         to provide print queue management whitin 4D in Macintosh Portables.
  9.         
  10.         The idea is that when the user launches 4D, we take PrintMonitor out
  11.         of the System Folder with a call to PrintQueue(), the effect of this is
  12.         that if the user prints something from 4D PrintMonitor will not be
  13.         launched and therefore it will not attempt to print and bother the user
  14.         with messages, the user is using a Portable Macintosh and may not be
  15.         connected to a network at the moment, therefore he just wants the print
  16.         outs to be spooled but he doesn't want PrintMonitor to bother him.
  17.         Once they quit 4D we restore the place of PrintMonitor.  If the user
  18.         goes to his office and connects to a network he'll want to print, for
  19.         this he selects a menu option of 4D and we will restore PrintMonitor
  20.         in the system folder so it is launched by Backgrounder.
  21.         
  22.         Notice that if the user selects the chooser to select a printer before
  23.         he tell us he wants to print, background printing will be disabled from
  24.         the chooser automatically by the laserwriter driver. (Maybe I'll do something
  25.         about that)
  26.         
  27.         The other function we provide is management of the print queue within
  28.         4D, to dot this our ModifyPrintQueue() is called, which shows the current
  29.         spooled files in a window, in this window we allow the user to change
  30.         the print order.  PrintMonitor uses the files named 'Spool File 1',
  31.         'Spool File 2', ...etc, to change the order all we need to do is rename
  32.         these files, and change the name used to print a file can be taken out of the resource
  33.         of each of these files, under 'STR ' -8189.
  34.         
  35.         Note: PrintMonitor prints the files based on their creation date, but we
  36.         like to change the name to make it easier for us.
  37.         
  38.         
  39.     HISTORY:
  40.     
  41.     08/24/89 RB    New Today
  42.     
  43.     
  44.     SPECIAL INSTRUCTIONS:
  45.     
  46.     Compile in THINK C as a code resource, give the resource a name that will be used
  47.     from 4D to call this external, then use 4D Ext Mover to copy into the Proc.Ext file
  48.     of the database to have print queue management.
  49.     
  50. */
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. /*
  58.     This is the main function of this 4D external command, we receive an integer
  59.     parameter, if startQueue is non zero (true) then we hide print monitor inside
  60.     the spool folder, otherwise we put printmonitor back in the system folder.
  61.     If the spool folder does not exist we create it.
  62. */
  63.  
  64. #include "SetupA4.h"
  65.  
  66.  
  67. pascal void main(int *startQueue)
  68. {
  69.     CInfoPBRec info;
  70.     CMovePBRec move;
  71.     WDPBRec wd;
  72.     int err = 0;
  73.     SysEnvRec mac;
  74.     long spoolFolder, pMonitorFolder;
  75.     
  76.     RememberA0();
  77.     SetUpA4();
  78.     err = SysEnvirons(1, &mac);
  79.     wd.ioCompletion = 0L;
  80.     wd.ioWDIndex = 0;
  81.     wd.ioVRefNum = BootDrive;
  82.     wd.ioNamePtr = 0L;
  83.     wd.ioWDProcID = 0;
  84.     err = PBGetWDInfo(&wd,FALSE);
  85.     info.dirInfo.ioCompletion = 0L;
  86.     if (mac.systemVersion < 0x7000)
  87.         info.dirInfo.ioNamePtr = (StringPtr) "\pSpool Folder";
  88.     else
  89.         info.dirInfo.ioNamePtr = (StringPtr) "\pPrintMonitor Documents";
  90.     info.dirInfo.ioVRefNum = BootDrive;
  91.     info.dirInfo.ioFDirIndex = 0;
  92.     info.dirInfo.ioDrDirID = 0;
  93.     err = PBGetCatInfo(&info,FALSE);
  94.     if (err == fnfErr) {
  95.         if (mac.systemVersion < 0x7000)
  96.             info.dirInfo.ioNamePtr = (StringPtr) "\pSpool Folder";
  97.         else
  98.             info.dirInfo.ioNamePtr = (StringPtr) "\pPrintMonitor Documents";
  99.         err = CreateSpoolFolder(info.dirInfo.ioNamePtr);
  100.         info.dirInfo.ioVRefNum = BootDrive;
  101.         info.dirInfo.ioFDirIndex = 0;
  102.         info.dirInfo.ioDrDirID = 0;
  103.         err = PBGetCatInfo(&info,FALSE);
  104.     }
  105.     spoolFolder = info.dirInfo.ioDrDirID;
  106.     pMonitorFolder = info.dirInfo.ioDrParID;
  107.     if (mac.systemVersion >= 0x7000) {
  108.         info.dirInfo.ioNamePtr = (StringPtr) "\pExtensions";
  109.         info.dirInfo.ioVRefNum = BootDrive;
  110.         info.dirInfo.ioFDirIndex = 0;
  111.         info.dirInfo.ioDrDirID = 0;
  112.         err = PBGetCatInfo(&info,FALSE);
  113.         if (!err)
  114.             pMonitorFolder = info.dirInfo.ioDrDirID;
  115.     }
  116.     if (!err) {
  117.         if (*startQueue) {
  118.             move.ioDirID = pMonitorFolder;
  119.             move.ioNewDirID = spoolFolder;
  120.         }
  121.         else {
  122.             move.ioDirID = spoolFolder;
  123.             move.ioNewDirID = pMonitorFolder;
  124.         }
  125.         move.ioVRefNum = wd.ioWDVRefNum;
  126.         move.ioCompletion = 0L;
  127.         move.ioNewName = 0L;
  128.         move.ioNamePtr = (StringPtr) "\pPrintMonitor";
  129.         err = PBCatMove(&move,FALSE);
  130.     }
  131.     RestoreA4();
  132.     return;
  133.     asm {
  134.         dc.b "© Copyright 1989 Apple Computer, Inc. By Ricardo Batista"
  135.     }
  136. }
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145. /*
  146.     This function will create a 'Spool Folder' inside the system folder, it
  147.     is called when the Spool Folder was not found in the system folder as a
  148.     precaution, because the user may have just installed the system and no
  149.     spool folder exists.
  150. */
  151.  
  152.  
  153. int CreateSpoolFolder(char *fName)
  154. {
  155.     HParamBlockRec hp;
  156.     int err = 0;
  157.     
  158.     hp.ioParam.ioCompletion = 0L;
  159.     hp.ioParam.ioNamePtr = (StringPtr) fName;
  160.     hp.ioParam.ioVRefNum = BootDrive;
  161.     hp.fileParam.ioDirID = 0;
  162.     err = PBDirCreate(&hp,FALSE);
  163.     return(err);
  164. }
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.